Ext.define('AmpleHarvest.objects.groups.window.members.cToolbar',
{
	extend				: 'Ext.toolbar.Toolbar',
	alias				: 'widget.ampleharvest-objects-groups-window-members-ctoolbar',
	id					: 'groupMemberToolbar',
	alias				: 'widget.groupMemberToolbar',
	requires			:
	[
			'Ext.data.TreeStore', 
			'Ext.button.Button'//,
//			'AmpleHarvest.objects.groups.eventHandler.cWindowEvents'
	],

	initComponent		: function()
	{
		var obj_This = this;

		this.m_obj_Add = Ext.create("Ext.button.Button",
		{
			text		: 'Add',
			iconCls		: "menu-group-add-icon",
			handler		: function()
			{				
				var obj_Panel = this.up('ampleharvest-objects-groups-window-cgroupmembers');
				m_obj_AmpleHarvest_ViewPort
						.fireEvent(
								AmpleHarvest.objects.groups.eventHandler.cWindowEvents.C_STR_EVENT_GO_GROUP_ADD_MEMBER,
								obj_Panel
						);
			}

		}
		);

		this.m_obj_Remove = Ext.create("Ext.button.Button",
		{
			text		: 'Remove',
			disabled	: true,
			iconCls		: 'toolbar-article-navigation-files-delete',
			scope		: this,
			handler		: function(rowIndex)
			{
				var obj_Panel = this.up('ampleharvest-objects-groups-window-cgroupmembers');
				var recs = obj_Panel.getSelectionModel().getSelection();
				
				Ext.Array.each(recs, function(obj, index, arr_all)
				{
					var obj_Link = obj.get('ID');
					
					m_obj_AmpleHarvest_ViewPort
							.fireEvent(
									AmpleHarvest.groups.eventHandler.cWindowEvents.C_STR_EVENT_GO_GROUP_REMOVE,
									obj_Panel, obj_This, obj_Link, obj_Panel.m_str_RequestID
							);
				}
				);
			}
		}
		);
		
		this.m_obj_Status = Ext.create("Ext.button.Button",
		{
			text		: 'Status',
			disabled	: true,
			iconCls		: 'toolbar-article-navigation-files-edit',
			handler		: function(rowIndex)
			{
				var obj_Panel = this.up('ampleharvest-objects-groups-window-cgroupmembers');				
				var recs = obj_Panel.getSelectionModel().getSelection();
				
				Ext.Array.each(recs, function(obj, index, arr_all)
				{
					
					var str_userID = obj.get('ID');

					m_obj_AmpleHarvest_ViewPort
							.fireEvent(
									AmpleHarvest.groups.eventHandler.cWindowEvents.C_STR_EVENT_MEMBER_STATUS,
									obj_Panel, obj_This, str_userID, obj_Panel.m_str_RequestID
							);
				}
				);
			}
		}
		);


		this.callParent();

		this.add(this.m_obj_Add);
		this.add(this.m_obj_Remove);
		this.add(this.m_obj_Status);
	},
	
	set_ButtonStatus	: function(arr_Selection, obj_Button)
	{
		if (arr_Selection.length >= 1)
		{
			obj_Button.enable();
		}
		else
		{
			obj_Button.disable();
		}
	},

	set_Buttons		: function(arr_Selection)
	{
		this.set_ButtonStatus(arr_Selection, this.m_obj_Remove);
		this.set_ButtonStatus(arr_Selection, this.m_obj_Status);
	}
}
);